﻿//StarLine 星形
//vesion 1.0
//author 夏天的树人
package org.summerTree.graphics
{

	import flash.geom.Point;
	public class Star extends Base 
	{

		//private var LineColor:uint=0x000000;//默认是黑色
		public function Star()
		{

		}
        
		override public function clone():*
		{
			return new Star();
		}
			
		//创建星形
		//参数第一个意思长轴，第二个短轴，n为边数
		public function CreatStar(long_radius:Number,short_radius:Number,n:int=5,fillcolor:uint=0xffffff,alpha:Number=1):void
		{
			this.graphics.lineStyle(1,color);
			if (n <= 0) return;		
			var angle:Number=Math.PI / n;
			var tempArray:Array=new Array();
			for (var i:int=0; i < n * 2; i++)
			{
				if (i % 2 == 0)
				{
					var l_px:Number=long_radius * Math.cos(i * angle);
					var l_py:Number=long_radius * Math.sin(i * angle);
					tempArray.push(new Point(l_px,l_py));
				}
				else
				{
					var s_px:Number=short_radius * Math.cos(i * angle);
					var s_py:Number=short_radius * Math.sin(i * angle);
					tempArray.push(new Point(s_px,s_py));
				}
			}
			
			this.graphics.beginFill(fillcolor,alpha);
			this.graphics.moveTo(tempArray[0].x,tempArray[0].y);
			for (var j:int=0; j< n * 2; j++)
			{
				
				drawPoint(tempArray[j]);
			}
			this.graphics.lineTo(tempArray[0].x,tempArray[0].y);
			this.graphics.endFill();
						
		}
		//绘制线程序
		private function drawPoint(point:Point):void
		{
			this.graphics.lineTo(point.x,point.y);
		}
		////设置颜色
//		public function set color(value:uint):void
//		{
//			this.LineColor=value;
//		}
//		//获取颜色
//		public function get color():uint
//		{
//			return this.LineColor;
//		}
		////清除图像
//		public function clear():void
//		{
//			this.graphics.clear();
//		}
		
	}
}